<template id="player">
    <div class="search">
        <!-- 搜索框 -->
        <input v-model="music" @keyup.enter="search(music)" type="text" placeholder="搜索.." name="search">
        <button type="button" @click="search(music)">搜索</button>
    </div>
</template>
<script>
import { mets } from "@/play/play.js"; //axios调用api的方法的对象
import { data } from "@/play/data";    //全局变量
export default {
    name: 'searchView',
    data() {
        return {
            data
        }
    },
    methods: {
        //搜索歌曲的信息
        search: function (musicName) {
            //先将data中的musicList置空
            data.musicList = []
            //调用mets中的搜索api方法
            mets.searchMusic(musicName)
            for (var i = 0; i < 20; i++) {
                //一个个push进去
                data.musicList.push(mets.musicList[i])
            }
            console.log(data)
        },

        test: function () {

            console.log(this._data.data)

        }
    },

}

</script>


<style>
.search {
    background-image: url(image/音乐标志.png), url(image/音乐标志3.png);
    height: 100%;
    background-repeat: no-repeat;
    background-size: 10%, 10%;
    background-position: 55px 5px, 640px 8px;
}

input[type=text] {
    border: 1px solid #ccc;
    padding: 6px;
    margin-top: 27px;
    font-size: 17px;
    margin-left: 30%;
    margin-right: 20px;
    float: left;
    border-radius: 10px;
    background-image: url(image/搜索_search.png);
    background-size: 10%;
    background-repeat: no-repeat;
    background-position: 189px 5px;
}

button {
    background: #3498db;
    background-image: linear-gradient(to bottom, #3498db, #2980b9);
    border-radius: 28px;
    font-family: Arial;
    color: white;
    font-size: 20px;
    padding: 10px 20px 10px 20px;
    text-decoration: none;
    margin-top: 20px;
}

button:hover {
    background: #3cb0fd;
    background-image: linear-gradient(to bottom, #3cb0fd, #3498db);
    text-decoration: none;
    margin-top: 20px;
}
</style>
